{include file="../../../application/admin/view/public/head" /}
<div class="page-container p10">
    <form class="layui-form layui-form-pane" method="post" action="">
        <input id="id" name="id" type="hidden" value="{$info.id}">
        <div class="layui-form-item">
            <label class="layui-form-label">选择模块：</label>
            <div class="layui-input-block">
                <div class="layui-input-inline">
                  <select name="istuijian" lay-filter="istuijian" id="istuijian">
                      <option value="0" {if condition="$info['istuijian'] eq 0"}selected="selected" {/if}>推荐</option>
                      <option value="1" {if condition="$info['istuijian'] eq 1"}selected="selected" {/if}>发现</option>
                  </select>
                </div>
            </div>
            <div class="layui-input-block" style="margin-top: 10px;">
              <select name="mokuai_id" lay-filter="mokuai_id" id="mokuai_id">
              </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">广告图片：</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" id="adpic" lay-verify="required" value="{$info.pic}" placeholder="请输入广告图片链接地址" name="pic">
                <a href="https://www.gudian.org/tools/tt.html" target="_blank" class="layui-btn" style="margin-top: 5px;">
                  <i class="layui-icon">&#xe67c;</i>上传广告图片（宽750px，高370px）
                </a>
                <img src="{$info.pic}" class="yulantu" style="max-height: 100px;display: block;margin-top: 10px;" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">跳转链接：</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" lay-verify="required" value="{$info.jumpurl}" placeholder="请输入跳转链接" name="jumpurl">
            </div>
        </div>
        <!--<div class="layui-form-item">-->
        <!--    <label class="layui-form-label">跳转方式：</label>-->
        <!--    <div class="layui-input-block" style="border: 1px solid #f1f1f1;">-->
        <!--        <input type="radio" name="jumpstatus" {if condition="$info['jumpstatus'] eq 0"}checked {/if} value="0" title="App内">-->
        <!--        <input type="radio" name="jumpstatus" {if condition="$info['jumpstatus'] eq 1"}checked {/if} value="1" title="App外">-->
        <!--    </div>-->
        <!--</div>-->

                <input type="text" style="display:none;" name="jumpstatus" value="1">
        <!--<div class="layui-form-item">-->
        <!--    <label class="layui-form-label">广告名称：</label>-->
        <!--    <div class="layui-input-block">-->
        <!--        <input type="text" class="layui-input" value="{$info.adname}" placeholder="请输入" name="adname">-->
        <!--    </div>-->
        <!--</div>-->

        <!--<div class="layui-form-item">-->
        <!--    <label class="layui-form-label">广告描述：</label>-->
        <!--    <div class="layui-input-block">-->
        <!--        <input type="text" class="layui-input" value="{$info.desc}" placeholder="请输入" name="desc">-->
        <!--    </div>-->
        <!--</div>-->

        <!--<div class="layui-form-item">-->
        <!--    <label class="layui-form-label">顺序：</label>-->
        <!--    <div class="layui-input-block">-->
        <!--        <input type="text" class="layui-input" lay-verify="required" value="{$info.liebiaoshunxu}" placeholder="请输入显示顺序" name="liebiaoshunxu">-->
        <!--    </div>-->
        <!--</div>-->
        
        <div class="layui-form-item">
            <label class="layui-form-label">广告位置：</label>
            <div class="layui-input-block" style="border: 1px solid #f1f1f1;">
                <input type="radio" name="picadweizhi" {if condition="$info['picadweizhi'] eq 0"}checked {/if} value="0" title="模块上面">
                <input type="radio" name="picadweizhi" {if condition="$info['picadweizhi'] eq 1"}checked {/if} value="1" title="模块下面">
            </div>
        </div>
        
        <div class="layui-form-item">
            <label class="layui-form-label">状态：</label>
            <div class="layui-input-block" style="border: 1px solid #f1f1f1;">
                <input type="radio" name="status" {if condition="$info['status'] eq 0"}checked {/if} value="0" title="关闭">
                <input type="radio" name="status" {if condition="$info['status'] eq 1"}checked {/if} value="1" title="开启">
            </div>
        </div>
        
        <div class="layui-form-item center">
            <div class="layui-input-block">
                <input type="text" style="display:none" class="layui-input" value="2" placeholder="" name="adtype">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="formSubmit" data-child="true">保 存</button>
            </div>
        </div>
    </form>

</div>
{include file="../../../application/admin/view/public/foot" /}

<script type="text/javascript">
    layui.use(['form', 'jquery', 'layer'], function () {
        // 操作对象
        var form = layui.form
                , layer = layui.layer
                , $ = layui.jquery;
        function selectChangeTuijian(form, index) {
            $("#mokuai_id").html("");
            form.render();
            $.post("/app.php/vod/getallrecommend", {'jiami':-1}, function(res) {
                layer.close(index); 
                if(res.code == 1) {
                    var list = res.data;//console.log(list)
                    if(list.length > 0) {
                        var str = "";
                        var mokuai_id = parseInt("{$info['mokuai_id']}");
                        for(var i in list) {
                            if(mokuai_id == list[i].id) {
                                str += '<option value="' + list[i].id + '">' + list[i].name + '</option>';
                            } else {
                                str += '<option value="' + list[i].id + '">' + list[i].name + '</option>';
                            }
                        }
                        $("#mokuai_id").html(str);
                        form.render();
                    }
                }
            }, "json");
        }
        
        function selectChangeFaxian(form, index) {
            $("#mokuai_id").html("");
            form.render();
            $.post("/app.php/vod/getallexplore", {'jiami':-1}, function(res) {
                layer.close(index); 
                if(res.code == 1) {
                    var list = res.data;//console.log(list)
                    if(list.length > 0) {
                        var str = "";
                        var mokuai_id = parseInt("{$info['mokuai_id']}");
                        for(var i in list) {
                            str += '<option value="' + list[i].id + '" disabled="disabled">' + list[i].name + '</option>';
                            if(list[i].childs.length > 0) {
                                for(var j in list[i].childs) {
                                    if(mokuai_id == list[i].childs[j].id) {
                                        str += '<option value="' + list[i].childs[j].id + '" selected="selected">' + list[i].childs[j].name + '</option>';
                                    } else {
                                        str += '<option value="' + list[i].childs[j].id + '">' + list[i].childs[j].name + '</option>';
                                    }
                                }
                            }
                        }
                        $("#mokuai_id").html(str);
                        form.render();
                    }
                }
            }, "json");
        }
        var istuijian = parseInt("{$info['istuijian']}");
        if(istuijian == 0 || isNaN(istuijian)) {
            selectChangeTuijian(form);
        }
        if(istuijian == 1) {
            selectChangeFaxian(form);
        }
        form.on('select(istuijian)', function(data){
            var index = layer.load(1);
            if(data.value == 0) {
                selectChangeTuijian(form, index);
            }
            if(data.value == 1) {
                selectChangeFaxian(form, index);
            }
		});
		
        $("#adpic").change(function() {
            $(".yulantu").attr("src", $(this).val());
        });
    });
</script>

</body>
</html>